package org.itboys.core.controller.web.wallet;

import org.itboys.core.entity.mysql.wallet.SundayWallet;
import org.itboys.core.service.mysql.web.SundayWalletService;
import org.itboys.core.util.MybatisParamUtil;
import org.itboys.framework.query.JsonPageUtils;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.param.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author：贾琦磊
 * @Date：2018/12/11
 * @Description：web端用户钱包管理
 */
@Controller
@RequestMapping("/sunday/web/wallet")
public class SundayWalletController extends BaseController{
    @Autowired
    private SundayWalletService walletService;

    @RequestMapping("/index")
    public String withdraw_index(HttpServletRequest request, HttpServletResponse response) {
        return "/sunday/wallet/index";
    }
    @RequestMapping("/detail")
    public String wallet_detail(HttpServletRequest request, HttpServletResponse response,Model model
            , @RequestParam(value = "walletId", required = false) Long walletId) {
        model.addAttribute("walletId",walletId);
        return "/sunday/wallet/detail";
    }
    @RequestMapping("/select")
    public void select(HttpServletRequest request,
                       HttpServletResponse response
    ) {
        MybatisParamUtil paramUtil = new MybatisParamUtil(request);
        PageResult<SundayWallet> result = walletService.selectWallet(paramUtil);
        JsonPageUtils.renderJsonPage(result.getTotal(), result.getData(), response);
    }

}
